A5WS_Save_User_Values Function

This function is deprecated and this page will be removed in the near future. Use A5WS_Save_WebUser_Values().

Syntax

Result as P = a5ws_Save_User_Values(P CurrentForm [,* request ])

Arguments

Result

The result value is not meaningful if the function is being used in a web component. result.errors = Will return TRUE if any errors are found during processing. result.error_text = Error messages returned.

CurrentForm

The CurrentForm variable, a system variable that refers to the contents of the dialog component.

request

The Request system variable. This variable explicitly passes all request variables to the function. Users are identified by a value in the request.variables property of the request variable. request.variables.guid = The user GUID value for the desired user record

Description

This function is deprecated after Alpha Five Version 9. The function A5WS_Save_WebUser_Values() should be used instead.

Discussion

This function is deprecated after Alpha Five Version 9. The function A5WS_Save_WebUser_Values() should be used instead.

The A5WS_Save_User_Values() function validates values from controls in a dialog component and then saves the values to fields in the Web Security User table. Only values passed in the request.variables property of the request variable are saved.

The name of each control in the dialog must exactly match the name of the field in the user table. A list of valid field names can be found by using the A5WS_User_File_Field_List() function. It is used in the Server Validate event of a dialog component. Adding Users with a Web Component shows how the function is used in dialog component event.

If validation errors are detected, the form will be redisplayed with the error message shown at the top of the form and the variable CurrentForm.Has_Error will be TRUE. The user can then make corrections and resubmit the form. If the variable CurrentForm.Has_Error = .T. prior to calling the function, the function will test the security control values for validation and return any errors, but will not save the values. The security values will only be saved if CurrentForm.Has_Error =.F.

1. Display the Form > Properties menu page of the Dialog Builder.
2. Click in the Server Events > Validate property.

Note that CurrentForm and Request are the names of variables created by the Application Server.

A5WS_Save_User_Values(CurrentForm, Request)

Using the Function Outside of a Dialog Component

The function is designed to be used within Server Events of a dialog component. However, it can be used on any Xbasic code section on a web page or component to save various values for a specific user. It is helpful to get a list of valid field names currently being used in the user security table by using the A5WS_User_File_Field_List() function. One additional field named groups can be saved. Groups should contain a comma delimited or CR-LF delimited list of the security groups assigned to the user. The group values can be the group_guid value for each group or the group_name of each group.

? a5ws_User_File_Field_List()
= Email
Guid
Password
Ulink
Userid

The function will only save values for fields passed to the function in the Request system variable as request.variables. and will only save values for fields currently being used by the security system.

Security Settings may be defined to require values in certain User Verification Fields during data entry on the web. If these fields are included in the Request variables, they can not be blank, or the record will not be saved and an error message will be returned.

A value MUST be passed to the function to find the current user. This MUST be request.variables.guid. No other input value can be used to find an existing record.

If the guid value is not passed to the function, the guid value is blank, or the guid value doesn't match an existing record, a new record will be created. A userid value must be an input value for a new record, or the save is cancelled and returns an error message. Userid does not have to be entered for an existing record unless the value for userid is being changed.

This code will find the user with a guid="20860aa66cfa4feb83ba25887d303f59" and change the email address to "[email protected]". If no user is found with that guid, nothing is saved and an error message is returned.

dim request.variables.guid as c
dim request.variables.email as c
request.variables.guid = "20860aa66cfa4feb83ba25887d303f59"
request.variables.email = "[email protected]"

This code will enter a new user record with a userid = "[email protected]" and an email address with the same value. The new user record will have a password added with the value of "password". Since no guid is input, a new record is created. The function will automatically create a new guid value for the record when the record is saved.

dim request.variables.userid as c
dim request.variables.email as c
dim request.variables.password as c
request.variables.userid = "[email protected]"
request.variables.email = "[email protected]"
request.variables.password = "password"

This code will set the user's group assignments to "Administrators" and "Marketing". The function will only save groups that are valid values in security groups definitions.

dim request.variables.groups as c
request.variables.groups = "Administrators,Marketing"

An output pointer must be defined. The function will always return the guid value for a saved record as .Controls.guid.value. The function will also return values for any fields passed to the function in the Request system variable.

dim output as p
dim output.controls as p
dim output.controls.guid.value as c

The function will return the values saved as .controls..value. The result.errors value can be tested to determine if any errors occurred during processing. Any error messages will be should in the result.error_text value.

dim result as p
dim error_message as c
dim group_list as c
result = a5ws_Save_User_Values(output,request)
if result.errors = .T. then
    error_message = result.error_text
    end
end if 
user_guid = output.controls.guid.value

Limitations

DEPRECATED

See Also